//
//  ListTableViewCell.m
//  图片故事
//
//  Created by 刘鉴古 on 16/3/8.
//  Copyright © 2016年 helloApp. All rights reserved.
//

#import "ListTableViewCell.h"
#import "Header.h"
#define Screen [UIScreen mainScreen].bounds.size
@implementation ListTableViewCell
// 重写cell初始化方法
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        // 创建子视图
        [self setupSubsView];
    }
    return self;
}

- (void)setupSubsView {
    
    _detailImage = [[UIImageView alloc] init];
    
    _detailImage.contentMode=UIViewContentModeScaleAspectFill;
    
    [_detailImage.layer setMasksToBounds:YES];
    
    [self.contentView addSubview:_detailImage];
    
    _bgView = [[UIView alloc] init];
    
    _bgView.backgroundColor = [UIColor colorWithRed:97 / 255.0 green:97 / 255.0 blue:97 / 255.0 alpha:0.4];
    
    [self.contentView addSubview:_bgView];
    
    _titleLabel = [[UILabel alloc] init];

    _titleLabel.font =[UIFont fontWithName:@"Helvetica" size:16.0];
    _titleLabel.textAlignment = NSTextAlignmentLeft;
    _titleLabel.textColor = [UIColor whiteColor];

    [_bgView addSubview:self.titleLabel];
    
    _mapImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Map_1.png"]];

    [_bgView addSubview:self.mapImage];
    
    _mapLabel = [[UILabel alloc] init];
    
    _mapLabel.font = [UIFont systemFontOfSize:12];
    
    _mapLabel.textColor = [UIColor whiteColor];
    
    [_bgView addSubview:self.mapLabel];
}

- (void)layoutSubviews {

    [super layoutSubviews];
    
    [_bgView setFrame:CGRectMake(0, My_Height(190), Screen.width, My_Height(50))];
    
    _detailImage.frame = CGRectMake(0, 0, Screen.width, My_Height(240));
    
    [_titleLabel setFrame:CGRectMake(My_Width(10), 0, Screen.width, My_Height(25))];
    
    _mapImage.frame = CGRectMake(My_Width(10), My_Height(30), My_Width(15), My_Height(15));
    
    [_mapLabel setFrame:CGRectMake(My_Width(CGRectGetMaxX(self.mapImage.frame) + My_Width(8)), My_Height(30), My_Width(250), My_Height(15))];
}

@end
